﻿using Quartz;
using TaskMasterByQuartz.Domain.Enums;

namespace TaskMasterByQuartz.Domain.InterfaceRepository
{
    /// <summary>
    /// 调度中心
    /// </summary>
    public interface ISchedulerCenter
    {
        public Task<bool> CheckScheduleJobAsync(string jobGroupName,
            string jobName);
        /// <summary>
        /// 添加一个工作调度
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="runNumber"></param>
        /// <returns></returns>
        public Task AddScheduleJobAsync(string jobGroupName,
            string jobName,
            DateTimeOffset? endTime,
            JobTypeEnum jobType,
            string? requestUrl,
            string? headers,
            string? requestParameters,
            RequestTypeEnum? requestType,
            TriggerTypeEnum triggerType,
             string cron, DateTimeOffset beginTime, int? runTimes, int IntervalSecond, string description,
            long? runNumber = null);

        /// <summary>
        /// 暂停指定的计划
        /// </summary>
        /// <param name="jobGroup">任务分组</param>
        /// <param name="jobName">任务名称</param>
        /// <returns></returns>
        public Task StopScheduleJobAsync(string jobGroup, string jobName);

        /// <summary>
        /// 删除指定的计划
        /// </summary>
        /// <param name="jobGroup">任务分组</param>
        /// <param name="jobName">任务名称</param>
        /// <returns></returns>
        public Task DelScheduleJobAsync(string jobGroup, string jobName);

        /// <summary>
        /// 恢复运行暂停的任务
        /// </summary>
        /// <param name="jobName">任务名称</param>
        /// <param name="jobGroup">任务分组</param>
        public Task ResumeJobAsync(string jobGroup, string jobName);

        /// <summary>
        /// 获取指定 标识的作业（Job）的详细信息
        /// </summary>
        /// <param name="jobName">任务名称</param>
        /// <param name="jobGroup">任务分组</param>
        /// <returns></returns>
        public Task<IJobDetail> QueryJobDetailAsync(string jobGroup, string jobName);

        /// <summary>
        /// 获取指定作业（Job）关联的所有触发器（Triggers）
        /// </summary>
        /// <param name="jobName">任务名称</param>
        /// <param name="jobGroup">任务分组</param>
        /// <returns>包含所有触发器的列表</returns>
        public Task<IReadOnlyCollection<ITrigger>> QueryTriggersOfJobAsync(string jobGroup, string jobName);

        /// <summary>
        /// 立即执行
        /// </summary>
        /// <param name="jobKey"></param>
        /// <returns></returns>
        public Task<bool> TriggerJobAsync(JobKey jobKey);

        /// <summary>
        /// 获取job日志
        /// </summary>
        /// <param name="jobKey"></param>
        /// <returns></returns>
        public Task<List<string>> GetJobLogsAsync(JobKey jobKey);

        /// <summary>
        /// 获取任务运行次数
        /// </summary>
        /// <param name="jobKey"></param>
        /// <returns></returns>
        public Task<long> GetRunNumberAsync(JobKey jobKey);
    }
}
